<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>border动画4</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: #000;
        }

        *,
        *::before,
        *::after {
            box-sizing: border-box;
        }

        @keyframes rotate {
            100% {
                transform: rotate(1turn);
            }
        }

        .conic {
            position: relative;
            z-index: 0;
            width: 400px;
            height: 300px;
            margin: 20px;
            border-radius: 10px;
            /*此乃障眼法， 去掉这个属性就比较好理解实现原理了 */
            overflow: hidden;
            padding: 2rem;


        }

        .conic::before {
            content: '';
            position: absolute;
            z-index: -2;
            left: -50%;
            top: -50%;
            width: 200%;
            height: 200%;
            background-color: #1a232a;
            background-repeat: no-repeat;
            background-position: 0 0;
            background-image: conic-gradient(transparent, rgba(168, 239, 255, 1), transparent 30%);
            animation: rotate 4s linear infinite;
        }

        .conic::after {
            content: '';
            position: absolute;
            z-index: -1;
            left: 6px;
            top: 6px;
            width: calc(100% - 12px);
            height: calc(100% - 12px);
            background: #000;
            border-radius: 5px;
        }

        .conic-demo::after {
            animation: opacityChange 5s infinite linear;
        }

        @keyframes opacityChange {
            50% {
                opacity: .5;
            }

            100% {
                opacity: 1;
            }
        }
    </style>
</head>

<body>
    <div class="conic"></div>
    <div class="conic conic-demo"></div>
</body>

</html>